package com.gulimall.product.web;

import com.gulimall.common.core.domain.Result;
import com.gulimall.product.domain.vo.SkuItemVo;
import com.gulimall.product.service.ISkuInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.concurrent.ExecutionException;

@RestController
@Slf4j
@RequestMapping("/product/itemInfo")
public class ItemController {
    @Resource
    private ISkuInfoService skuInfoService;

    /**
     * 获取商品详情信息
     */
    @GetMapping("/{skuId}")
    public Result<SkuItemVo> getItemInfo(@PathVariable("skuId") Long skuId) throws ExecutionException, InterruptedException {
        log.info("要查询的商品的skuId为：{}",skuId);
        SkuItemVo skuItemVo = skuInfoService.getItemInfo(skuId);
        return Result.ok(skuItemVo);
    }

    /**
     * 获取spu的规格参数信息
     */
//    @GetMapping
//    public Result getSpuInfo(){
//        List<SkuItemVo.SpuItemBaseAttrVo> spuInfo = skuInfoService.getSpuInfo();
//        return Result.ok(spuInfo);
//    }
}
